<#include "/WEB-INF/view/inc/inc.html"/>
<@html qmask=0>
<script type="text/javascript">
    function getcomment(div,id){
        var data ={y_comment_srcid:id,y_comment_srctable:"t_y_idea"};
        var html = qiao.ajax({url:"/y/c/comment",data:data, dataType:'html'});
        $('#'+div).empty().append(html);
    }
</script>
<div class="container">
    <div class="row">


        <div id="left" class="col-xs-8 col-sm-9 col-md-5 col-lg-5">
            <div class="clearfix">
                <h4>
                    <ol class="breadcrumb">
                        <li><a href="javascript:void(0);" onclick="projectnameclick(${pid})">${project.y_project_name}-${pid}</a> </li>
                        <li class="active">${(plan.y_idea_name)!""}-${parentid}</li>
                        <li class="active"><@bsbutton id="sortbtn" size='xs' icon='sort' class='editbtn'/>
                            &nbsp;<@bsbutton id="commentbtn" size='xs' icon='comment' class='editbtn'/>
                            &nbsp;<@bsbutton id="parentbtn" size='xs' icon='arrow-up' class='editbtn'/></li>
                    </ol>

                </h4>
                <@bsuls lis=listmyultop icons='ok,th-list,eye-open,retweet,remove' />
            </div>
            <!--自己的计划，
            团队创建 自己认领，队长分配我的-->
            <div class="clearfix">
                <@bsuls lis=listmyul icons='ok,th-list,eye-open,retweet,remove' />
            </div>
        </div>
        <div id="right" class="col-xs-4 col-sm-9 col-md-4 col-lg-4">
            <div class="clearfix" style="margin-left: -86px;padding-top: 2px;">
            <h4><ol class="breadcrumb" style="background-color:transparent;text-align: right;">
                <li>评论列表</li>
                </ol>
            </h4>
            <@bsverttabs lis=listcoumentul>
            <#if listmyultop??>
                <#list listcoumentul as li>
                    <@bsverttab id=li.id num=li_index>
                    <div id="vtabdiv${li.id}"></div>
                    <#if li.id?substring(2)!="">
                        <script type="text/javascript">getcomment("vtabdiv${li.id}",${li.id?substring(2)})</script>
                    </#if>
                    </@bsverttab>
                </#list>
            </#if>
            </@bsverttabs>
            </div>
        </div>


        <div class="col-xs-12 col-sm-3 col-md-3 col-lg-3">
            <div class="jumbotron" style="padding: 20px;">
                <h2>计划</h2>

                <p style="margin:0;font-size: 15px;">
                    严格执行<br>
                    不能错过一次<br>
                    记得分享监督。
                </p>
            </div>

            <div class="list-group" style="position:fixed;top:270px;margin-right:20px;" id="myNav">

            </div>
        </div>
    </div>
</div>

<script type="text/javascript">
    $(document).ready(function () {
        $("#myNav").affix({
            offset: {
                top: 125
            }
        });

        var dddddfunc =function (){
            alert($(this).parent().attr("id"));
            var data = {};
            data["ids"] = $(this).parent().attr("id");
            data["ids1"] = "ddd";
            data["ids2"] = {"dd":1,"ss":"222rr","12":[1,2],"obj":{a:1,b:2,c:3,d:4,f:5,g:6,h:7,i:8,j:9,k:10,l:11}};
            data["ids3"] = [1,2,3];
            ci.debug(lisort.getData());

//            ci.debug(data);
        };
        var delfunc =function (){
            var id = $(this).parent().attr("id");
            id = id.replace("id","");
            $.dely(id,"idea");
        };
        var donefunc = function(){

            var id = $(this).parent().attr("id");
            id = id.replace("id","");
            var data = {};
            data["row.id"] = id;
            var idea = $.findy("idea",data,function(idea){
                if(idea['y_idea_status']<10){
                    data["row.y_idea_status"] = 10;
                }else{
                    data["row.y_idea_status"] = 5;
                }
                $.savey("idea",data);
            });
        };
        var retwen = function (){
            //src 为源头 实物：计划 项目，
            //rela 关联 job 评论 人员关系
            var id = $(this).parent().attr("id");
            id = id.replace("id","");
            var data = {"row.y_rela_srcid":id,'row.y_rela_srctable':'t_y_idea'};
            data["row.y_rela_relatable"] = "t_y_job";
            data["row.y_rela_relaid"] = 1;
            data["row.y_rela_type"] = 0;
            if(false){
                data["row.id"] = "";
            }else{
                data["row.id"] = "";
            }
            $.savey("rela",data);
        };

        var listfunc =function (){
            var id = $(this).parent().attr("id");
            id = id.replace("id","");
            qiao.to("${base}/y/c/plan/${pid}-"+id);
        };
        var lisort = new qiao.order(function(data){
            for(var i =0;i<data.length;i++){
                var p = data[i];
                var editid = p.id;
                if(editid){
                    var datap = {"row.id":editid};
                    datap["row.y_idea_sort"] = p.num;
                    $.savey("idea",datap,true);
                }
            }
        });
        var sortfunc =function (){
            <#list listmyul as myplan>
            <#if myplan.id!='id'>
            var aa${myplan_index+1} = {id: ${myplan.id?substring(2)}, name: '${myplan.text}', num: ${myplan.sort !(myplan_index+1)}};
            lisort.addItem(aa${myplan_index+1});
            </#if>
            </#list>
            lisort.showPanel();
        };
        var commshow = 1;
        var commentfunc = function (){
            if(commshow){
                $("#left").removeClass().addClass(  "col-xs-10 col-sm-9 col-md-9 col-lg-9");
                $("#right").css("display","none");
                commshow = 0;
            }else{
                $("#left").removeClass().addClass(  "col-xs-10 col-sm-9 col-md-5 col-sm-5");
                $("#right").css("display","inline");
                commshow = 1;
            }
        }

        $("#sortbtn").kq_bind("click",sortfunc,{'title':"排序"});
        $("#commentbtn").kq_bind("click",commentfunc,{'title':"评论"});
        $(".okclass").kq_bind("click",donefunc,{'title':"完成"});
        $(".th-listclass").kq_bind("click",listfunc,{'title':"详细"});

        $(".eye-openclass").kq_bind("click",dddddfunc,{'title':"关注"});

        $(".removeclass").kq_bind("click",delfunc,{'title':"删除"});
        $(".retweetclass").kq_bind("click",retwen,{'title':"重复每天执行"});

        $('ul>li').kq_dbclickedit(function(editid){
            var editval=$("#"+editid).val();//获取更改内容
            $("#"+editid).parent().html(editval); //将点击的td中原内容改为输入的新内容

            var data = {"row.y_idea_parentid":'${parentid}',"row.y_project_id":'${pid}'};
            data["row.y_idea_name"] = editval;
            if(editid){
                data["row.id"] = editid.replace("edit_id","");
            }else{
                data["row.id"] = "";
            }
            $.savey("idea",data);
        });

        $("#parentbtn").kq_bind("click",function(){
            if("${(plan.y_idea_parentid)!""}" != ""){
                qiao.to("${base}/y/c/plan/${pid}-${(plan.y_idea_parentid)!""}");
            }else{
                qiao.to("${base}/y/c/project");
            }

        },{'title':"上级"});
    });
    function projectnameclick(projectid){
        qiao.to("${base}/y/c/plan/"+projectid);
    }


</script>
<@backtotop/>
</@html>
